package com.mz361.common.config.properties;//package com.mz361.api.config.properties;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class AliYunConfig {

    @Value("${spring.alicloud.AccessKeyID}")
    private String AccessKeyID;
    @Value("${spring.alicloud.AccessKeySecret}")
    private String AccessKeySecret;


    @Bean
    public com.aliyun.bailian20231229.Client client() {
        try {
            com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                    // 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
                    .setAccessKeyId(AccessKeyID)
                    // 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
                    .setAccessKeySecret(AccessKeySecret);
            // Endpoint 请参考 https://api.aliyun.com/product/bailian
            config.endpoint = "bailian.cn-beijing.aliyuncs.com";
            return new com.aliyun.bailian20231229.Client(config);
        } catch (Exception e) {
            log.info("aliyun init Client error {} ", e.getMessage());
        }
        return null;
    }
}
